Skip to main content

Display

MetadataViews.Display

Display MetadataView returns the following:

  • name: String - The name of the object.
  • description - A written description of the object.
  • thumbnail: AnyStruct - Small thumbnail representation of the object.
    • url - This field should be a web-friendly file (i.e JPEG, PNG) that can be displayed in lists, link previews, etc.
import UFC_NFT from 0xUFCNFTADDRESS
import MetadataViews from 0xMETADATAVIEWSADDRESS

pub fun main(address: Address, id: UInt64): MetadataViews.Display {
let account = getAccount(address)

let collectionRef = account.getCapability(UFC_NFT.CollectionPublicPath)
.borrow<&{UFC_NFT.MomentNFTCollectionPublic}>()
?? panic("Could not borrow capability from public collection")

let nft = collectionRef.borrowMomentNFT(id: id)
?? panic("Couldn't borrow momentNFT")

return nft.resolveView(Type<MetadataViews.Display>())! as! MetadataViews.Display
}